﻿using Castle.DynamicProxy;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Code.Services
{
    /// <summary>
    /// 拦截器
    /// </summary>
    public class LogInterceptor : IInterceptor
    {
        /// <summary>
        /// 拦截
        /// </summary>
        /// <param name="invocation">调用</param>
        /// <exception cref="NotImplementedException"></exception>
        public void Intercept(IInvocation invocation)
        {
            //调用方法之前
            //..........

            var value = invocation.GetArgumentValue(0);
            invocation.SetArgumentValue(0, value);

            invocation.Proceed();

            //调用方法之后 
            //...........
            var returnval = invocation.ReturnValue;
        }
    }
}
